package main

import (
	"awesomeProxy/config"
	"awesomeProxy/system/proxy"
	"net/http"
	_ "net/http/pprof"
	"os"
	"time"
)

func main() {
	go func() {
		http.ListenAndServe(":9956", nil)
	}()
	if len(os.Args) > 1 {
		client := proxy.ProxyClient{
			ProxyHost: config.GetConfigByKey("client.server_host").(string),
			ProxyPort: int(config.GetConfigByKey("client.server_port").(float64)),
			//TargetHost: "localhost",
			//TargetPort: 80,
			UniqueId:   config.GetConfigByKey("unique_id").(string),
			TargetHost: config.GetConfigByKey("client.target_host").(string),
			TargetPort: int(config.GetConfigByKey("client.target_port").(float64)),
		}
		go client.Start()
	} else {
		server := proxy.ProxyServer{}
		go server.StartServer(int(config.GetConfigByKey("server.port").(float64)))
	}
	for true {
		time.Sleep(time.Second * 10)
	}

}
